<template>
<div class="imgDiv">
  <span style="font-size:15px;">{{waitText}}</span>
  <x-img :src="src" @on-success="success" @on-error="error" class="ximg-demo" error-class="ximg-error"></x-img>
  <!--<div v-show="show">
    <br>
    <span style="font-size:15px;color:red;">关注下面公众号，看看2018年你靠什么吃饭</span>
    <br>
    <x-img :src="srcQr" class="ximg-qr"></x-img>
  </div>-->
</div>
</template>
<script>
import {XImg} from 'vux'
import srcQr from '@/assets/mchw.jpg'

export default {
  components: {
    XImg
  },
  data () {
    return {
      src: '/oo/img?name=' + this.$route.params.name +"&_"+new Date().getTime(),
      waitText: '等待加载...',
      srcQr: '',
      show: false
    }
  },
  methods: {
    success(src, ele) {
      const span = ele.parentNode.querySelector('span')
      ele.parentNode.removeChild(span)
      this.show=true
      this.srcQr=srcQr
    },
    error () {
      this.waitText = "加载失败!";
    }
  }
}
</script>
<style scoped>
.imgDiv{
  padding: 5px;
  text-align:center;
}
.ximg-demo {
  width: 100%;
  height: auto;
}
.ximg-error {
  //background-color: yellow;
}
.ximg-error:after {
  content: '加载失败';
  color: red;
}
.ximg-qr{
  width: 200px
}
</style>